package com.google.shop.product.controller.qqlogin;

import com.qq.connect.QQConnectException;
import com.qq.connect.api.OpenID;
import com.qq.connect.api.qzone.UserInfo;
import com.qq.connect.javabeans.qzone.UserInfoBean;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
/* loaded from: app.jar:BOOT-INF/classes/com/google/shop/product/controller/qqlogin/Test.class */
public class Test {
    private static final Logger log = LoggerFactory.getLogger(Test.class);

    @RequestMapping({"api/qqlogin2"})
    public String connection(HttpServletRequest request, HttpServletResponse response, Map<String, Object> map) throws QQConnectException {
        String openID = new OpenID("1F059B3B231431233B314AF9CAF65E03").getUserOpenID();
        UserInfoBean userInfoBean = new UserInfo("1F059B3B231431233B314AF9CAF65E03", openID).getUserInfo();
        if (userInfoBean.getRet() == 0) {
            String name = removeNonBmpUnicode(userInfoBean.getNickname());
            String imgUrl = userInfoBean.getAvatar().getAvatarURL100();
            map.put("openId", openID);
            map.put("name", name);
            map.put("imgUrl", imgUrl);
        } else {
            log.info("很抱歉，我们没能正确获取到您的信息，原因是： " + userInfoBean.getMsg());
            System.out.println("很抱歉，我们没能正确获取到您的信息，原因是： " + userInfoBean.getMsg());
        }
        return map.toString();
    }

    public String removeNonBmpUnicode(String str) {
        if (str == null) {
            return null;
        }
        String str2 = str.replaceAll("[^\\u0000-\\uFFFF]", "");
        if ("".equals(str2)) {
            str2 = "($ _ $)";
        }
        return str2;
    }
}
